﻿namespace Nomo.UnityEditorModule
{
    [UnityEditor.CanEditMultipleObjects]
    [UnityEditor.CustomEditor(typeof(UnityCoreModule.UI.Circle))]
    internal sealed class CircleEditor : UnityEditor.UI.GraphicEditor
    {
        private UnityEditor.SerializedProperty _texture;
        private UnityEditor.SerializedProperty _segments;
        private UnityEngine.GUIContent         _textureGUIContent;
        private UnityEngine.GUIContent         _segmentsGUIContent;

        protected override void OnEnable()
        {
            base.OnEnable();
            _texture            = serializedObject.FindProperty("texture");
            _segments           = serializedObject.FindProperty("segments");
            _textureGUIContent  = new UnityEngine.GUIContent(nameof(UnityCoreModule.UI.Circle.Texture),  "纹理");
            _segmentsGUIContent = new UnityEngine.GUIContent(nameof(UnityCoreModule.UI.Circle.Segments), "边数");
            SetShowNativeSize(_texture.objectReferenceValue != null, true);
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            UnityEditor.EditorGUILayout.PropertyField(_texture, _textureGUIContent);
            AppearanceControlsGUI();
            UnityEditor.EditorGUILayout.PropertyField(_segments, _segmentsGUIContent);
            RaycastControlsGUI();
            SetShowNativeSize(_texture.objectReferenceValue != null, false);
            NativeSizeButtonGUI();
            serializedObject.ApplyModifiedProperties();
        }
    }
}
